﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EpidemicSimulator.states;
using GraphMLComplexType;
using QuickGraph;
using System.Xml.Serialization;
using EdgeWithAttributes;
namespace EpidemicSimulator
{
    public class SocialNetworkNode : IGraphMLComplexType
    {
        public UndirectedGraph<SocialNetworkNode, EdgeWithAttributes<SocialNetworkNode>> socialNetwork { get; set; } 
        private Dictionary<string, string> m_keys;
        private static int i = 0;

        public SocialNetworkNode()
        {
            m_keys = new Dictionary<string,string>();
            Id = Guid.NewGuid();
        }

        public SocialNetworkNode(Dictionary<string, string> dict)
        {
            m_keys = dict;
        }

        //[XmlAttribute("id")]
        public Guid Id
        {
            get;
            set;
        }

        //[XmlAttribute("x")]
        public double x;

        //[XmlAttribute("y")]
        public double y;

        //[XmlAttribute("width")]
        public double Width;

        //[XmlAttribute("height")]
        public double Height;

        //[XmlAttribute("keys")]
        public Dictionary<string, string> Keys
        {
            get { return m_keys; }
            set { m_keys = value; }
        }

        //[XmlAttribute("state")]
        public State state { get; set; }
        public State newState { get; set; }

        public void stateAction(long simTime)
        {
            state.stateAction(simTime);
        }

        public void infect(long simTime)
        {
            state.infect(this, simTime);
        }

        public static string vertexIdentity<TVertex>(TVertex v) where TVertex : SocialNetworkNode
        {
            return v.Id.ToString();// +" " + v.Keys["importance"];
        }

        public static string edgeIdentity<TVertex, TEdge>(TEdge edge)
            where TVertex : SocialNetworkNode
            where TEdge : EdgeWithAttributes<SocialNetworkNode>
        {
            return edge.Source.Id.ToString() + "-" + edge.Target.Id.ToString();
        }
    }
}
